<template>
<!-- 拖拽列宽容器 -->
<div :class="{'rx-table-resize':colsResizable}">
  <table class="rx-table">
    <thead>
      <!-- 头部插槽 -->
      <slot name="thead"></slot>
    </thead>
    <tbody>
      <slot></slot>
    </tbody>
    <tfoot>
      <slot name="tfoot"></slot>
    </tfoot>
  </table>
<!-- 拖拽列宽bar -->
  <div v-if="colsResizable" class="rx-table-reize-bar" :style="{left:left+'px'}">
    <div class="rx-table-reize-barline"></div>
  </div>
</div>
</template>
<script>
export default {
  name:'rx-table',
  props: {
    colsResizable: {
      type: Boolean,
      default: false
    },
    sort: {
      type: String
    },
    desc: {
      type: Number
    }
  },
  data() {
    return {
      left: 0
    };
  },
  watch:{
    desc(val){

    },
    sort(val){

    }
  },
  methods:{
    click(){

    }
  },
  mounted(){

  }
};
</script>
<style lang="scss">
/* 变量 */
$resizeBar:#D5E6F1;
$resizeBarline:#bed5fb;
$th:#666;
$thbg:#f2f2f2;
$border:1px solid #C4CAD7;

/* 表格样式 */
.rx-table{
  width: 100%;
  table-layout: fixed;

  /* 表头start */
  &>thead{
    border: $border;

    &>tr>th{
      padding: 12px 10px;
      color:$th;
      background: $thbg;
      white-space: nowrap;
      font-weight: bold;
    }
  }
  /* 表头 end*/

  /* 表体 start*/
  &>tbody{
    border :$border;
    border-top: transparent;

     &>tr{
       border-bottom: 1px solid #dde2eb;

      &:last-child{
        border-bottom: transparent;
      }
     }

     &>tr>td{
      padding: 12px 10px;
      line-height: 20px;
      vertical-align: middle
    }
    &>tr:nth-child(odd)>td{
      background: #fff;
    }
    &>tr:nth-child(even)>td{
      background: #f9fbfc;
    }
    &>tr:hover>td{
      background: #eaf1ff !important;
    }
  }
  /* 表体end */

  /* 表足 */
  &>tfoot>tr>td{
    padding: 12px 10px;
  }
}

/*调整列宽 start*/
.rx-table-resize{
  position: relative;
}
.rx-table-resize-bar{
  position: absolute;
  top: 0;
  height: 0;
  width: 10px;
  background: $resizeBar;
  text-align: center;
  cursor: col-resize;

// 拖动时，显示虚线
  &.moving>.rx-table-resize-barline{
    border-left-style: dashed;
  }
}
.rx-table-resize-barline{
  display: inline-block;
  width: 1px;
  height: 100%;
  border-left: 1px solid $resizeBarline;
}
/*调整列宽 end*/
</style>

